//
// Created by 吴锐 on 2022/3/2.
//

#include "iostream"

using namespace std;

class MyAdd {
public:
    int operator()(int v1, int v2) {
        return v1 + v2;
    }
};

void test01() {
    MyAdd myAdd;
    cout << myAdd(10, 10) << endl;
}

class MyPrint {
public:
    MyPrint() {
        this->count++;
    }

    void operator()(string test) {
        cout << test << endl;
    }

    int count;
};

void test02() {
    MyPrint myPrint;
    myPrint("hello world");
    myPrint("hello world");
    myPrint("hello world");
    myPrint("hello world");

    cout << "myPrint调用的次数为: " << myPrint.count << endl;
}

void doPrint(MyPrint &mp, string test) {
    mp(test);
}

void test03() {
    MyPrint myPrint;
    doPrint(myPrint, "hello c++");
}

int main() {
//    test01();
//    test02();
    test03();
    return 0;
}